package com.walter.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.walter.domain.TeacherInfo;
import com.walter.service.TeacherInfoService;
import com.walter.service.impl.TeacherInfoServiceImpl;

public class TeacherByNameServlet extends HttpServlet {
	private TeacherInfoService tInfoService = new TeacherInfoServiceImpl();

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("searchName");
		System.out.println(name);
		if (!name.equals("") || !"".equals(name)) {
			List<TeacherInfo> list= tInfoService.getByName(name);
			if(list.isEmpty()){
				System.out.println("nonono");
			}
			// 2.将客户列表放入request域
			request.setAttribute("list", list);
			request.getRequestDispatcher("/jsp/index.jsp").forward(request, response);
		}
		else
			request.getRequestDispatcher("/TeacherInfo").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}